Skip to content

sort: fix workshop search missing current display names - #5921

Open
Alistair-Afton wants to merge 3 commits into
DFHack:developfrom
Alistair-Afton:fix-workshop-search-names
Open

Alistair-Afton wants to merge 3 commits into
DFHack:developfrom
Alistair-Afton:fix-workshop-search-names

Conversation

@Alistair-Afton

Copy link
Copy Markdown
Contributor

Summary

  • Fixes BUG: Searching for Stoneworker's Workshop #5711: searching the Places/Workshops list for "Stoneworker's Workshop" found nothing because the search key was built from the enum item name (Masons) and a stale df-structures name attr ("Mason's Workshop")
  • Add each workshop's getName() output to the search key so searches match what the list actually displays
  • Same fix applied to the task search key in plugins.sort.info
  • Also covers custom workshop names (e.g. "Screw Press", "Soap Maker's Workshop") which had no searchable name at all
  • Companion data fix in workshop_type: update name attrs to current in-game names df-structures#907 corrects the stale attrs themselves

Testing

  • In a live fort on 53.16, extracted the actual get_search_key_fn from the Places overlay and ran it on real workshops: Masons workshops now produce "Stoneworker's Workshop" in their key, and custom workshops produce their real names

Searching the Places/Workshops list for 'Stoneworker's Workshop' found
nothing because the search key was built from the enum item name and a
stale df-structures name attr. Add each workshop's getName() output to
the search key so searches match what the list actually displays, and
cover custom workshop names (e.g. 'Screw Press') that have no enum
attr at all.
@Alistair-Afton
Alistair-Afton force-pushed the fix-workshop-search-names branch from 0e87836 to 4e3c712 Compare September 17, 2026 11:19
Comment thread plugins/lua/sort/info.lua Outdated
-- the display name may differ from the enum item name (e.g.
-- Masons -> "Stoneworker's Workshop") and is the raw-defined
-- name for custom workshops
local name = df.new('string')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using dfhack.buildings.getName here; this convenience method avoids having to manually construct the output parameter - which you're leaking because you didn't delete it afterwards

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1138e90 - both sites now use dfhack.buildings.getName instead of df.new('string').

Comment thread plugins/lua/sort/places.lua Outdated
-- the display name may differ from the enum item name (e.g. Masons ->
-- "Stoneworker's Workshop") and is the raw-defined name for custom
-- workshops
local name = df.new('string')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue here - this code leaks the string created with df.new

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1138e90 - both sites now use dfhack.buildings.getName instead of df.new('string').

@Alistair-Afton

Copy link
Copy Markdown
Contributor Author

Done — switched both sites to dfhack.buildings.getName, which returns the name directly and drops the leaked df.new('string') allocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Searching for Stoneworker's Workshop

2 participants